<?php

/**
 * Employee form.
 *
 * @package    virtualstore
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class EmployeeForm extends BaseEmployeeForm
{
  public function configure()
  {
      $this->resetStamps();
      $this->resetDateWidgets();
      
      $this->setWidget('gender', new sfWidgetFormChoice(
              array('expanded' => true, 'choices' => array('M' => 'Male', 'F' => 'Female'))));
      $this->setWidget('age',
                new sfWidgetFormPlain(
                array('value' =>$this->getObject()->getAge())));
  }

  private function resetDateWidgets(){
      $log = sfContext::getInstance( )->getLogger();
      $log->debug('app_hiring_ages_min: ' .  sfConfig::get('app_hiringages_min'));
      $log->debug('app_hiring_ages_max: ' .  sfConfig::get('app_hiringages_max]'));

      $endYear = date('Y')- 17; //sfConfig::get('app_hiring_ages_min');
      $startYear = date('Y') - 75;//sfConfig::get('app_hiring_ages_max');

      
      $years = range($startYear, $endYear); //Creates array of years between 1920-2000
      $years_list = array_combine($years, $years); //Creates new array where key and value are both values from $years list
      $this->setWidget('dateOfBirth', new sfWidgetFormDate(array('years' => $years_list)));

  }
  protected function updateAgeColumn($value) {
        return false;
    }
}
